package app

import (
	_ "github.com/denisenkom/go-mssqldb"
	"github.com/jmoiron/sqlx"
)

var database *sqlx.DB

// 初始化数据库连接对象
func initDatabase() *sqlx.DB {
	config := GetConfig()
	var err error
	database, err = sqlx.Connect(config.DbConfig.Driver, config.DbConfig.Url)
	if err != nil {
		panic(err)
	}
	//db.SetMaxOpenConns(20)
	//db.SetMaxIdleConns(10)
	return database
}

func GetDatabase() *sqlx.DB {
	return database
}